package com.fly.caihong.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fly.caihong.R;
import com.fly.caihong.model.VideoItem;
import com.fly.caihong.utils.ApUtils;
import com.fly.caihong.utils.DataHandler;
import com.fly.caihong.utils.GlideUtils;

import java.io.File;
import java.util.List;

public class VideoAdapter extends BaseQuickAdapter<VideoItem, BaseViewHolder> {

    private String dirPath;

    public VideoAdapter(@Nullable List<VideoItem> data) {
        super(R.layout.layout_video_item, data);
        dirPath = DataHandler.EXTERNAL_STORAGE_PATH + File.separator
                + DataHandler.dataPaths.get("video/preview") + File.separator;
    }

    @Override
    protected void convert(BaseViewHolder helper, VideoItem item) {
        ImageView ivImage = helper.getView(R.id.iv_image);
        GlideUtils.loadRoundImage(ApUtils.getApp(), ivImage, dirPath + item.getPictures());
        ImageView ivProfile = helper.getView(R.id.iv_profile);
        GlideUtils.loadCircleAvatar(ApUtils.getApp(), ivProfile, item.getPhoto());
        helper.setText(R.id.tv_name, item.getNickName()).setText(R.id.tv_like_count, item.getLikeCount())
                .setText(R.id.tv_title, item.getTitle());
        helper.addOnClickListener(R.id.iv_pause);
        helper.addOnClickListener(R.id.fl_root);
    }
}
